#pragma once
#include "Comm.hpp"

class Server //读
{
public:
    Server()
        :_shmid(gdefault)
    {
        _key = ftok(filename,pro);
    }
    
    bool ShmCreat()
    {
        _shmid = shmget(_key,gsize,IPC_CREAT | IPC_EXCL | mode);
        if (_shmid < 0) return false;
        std::cout << "create shamremm sucess" << std::endl;
        return true;
    }
    
    void* Shmattach()
    {
         _ret = shmat(_shmid,nullptr,0);
        return _ret;
    }
    int Shmdattach()
    {
        return shmdt(_ret);
    }
    int ShmCtl()
    {
        return shmctl(_shmid,IPC_RMID,nullptr);
    }
    ~Server()
    {}
private:
    key_t _key;
    int _shmid;
    void* _ret;
};
